package enhanced.neural.network.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResponse<T> {

    private String code;

    private String msg;

    private String desc;

    private T data;

    public CommonResponse(T data) {
        this.data = data;
    }

    public CommonResponse(String code, String msg, String desc) {
        this.code = code;
        this.msg = msg;
        this.desc = desc;
    }


    public static <T> CommonResponse<T> error(String code, String msg, String desc) {
        return new CommonResponse<>(code, msg, desc);
    }

    public static <T> CommonResponse<T> success() {
        return new CommonResponse<>("200", "success", "成功");
    }

    public static <T> CommonResponse<T> success(T data) {
        CommonResponse<T> success = success();
        success.setData(data);
        return success;
    }
}
